package com.bms.common.response;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @author 姚炜琦
 * @description: 列表返回结果集
 */
@Data
@ApiModel(value = "列表返回结果集",description = "列表返回结果集")
public class PageResult<T> implements Serializable {

    /**
     * 总条数
     */
    @ApiModelProperty(name="total",value = "总条数",dataType = "long")
    private long total;

    /**
     * 结果集合
     */
    @ApiModelProperty(name="list",value = "数据",dataType = "List")
    private List<T> list;
    public PageResult() {}
    public PageResult(long total, List<T> list) {
        this.total = total;
        this.list = list;
    }
    public static <T> PageResult<T> toPageResult(long total, List<T> list){
        return new PageResult(total , list);
    }
    public static <T> Result<PageResult<T>> toResult(long total, List<T> list){
        return Result.success(PageResult.toPageResult(total,list));
    }
}
